/**
 */
package DentalClinicEMF.clinic.impl;

import DentalClinicEMF.clinic.Appointment;
import DentalClinicEMF.clinic.AppointmentStatus;
import DentalClinicEMF.clinic.Client;
import DentalClinicEMF.clinic.ClinicPackage;
import DentalClinicEMF.clinic.Service;

import java.util.Collection;
import java.util.Date;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Appointment</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link DentalClinicEMF.clinic.impl.AppointmentImpl#getDate <em>Date</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.AppointmentImpl#getStartBlock <em>Start Block</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.AppointmentImpl#getStatus <em>Status</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.AppointmentImpl#getHasClients <em>Has Clients</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.AppointmentImpl#getServices <em>Services</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AppointmentImpl extends MinimalEObjectImpl.Container implements Appointment {
	/**
	 * The default value of the '{@link #getDate() <em>Date</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDate()
	 * @generated
	 * @ordered
	 */
	protected static final Date DATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDate() <em>Date</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDate()
	 * @generated
	 * @ordered
	 */
	protected Date date = DATE_EDEFAULT;

	/**
	 * The default value of the '{@link #getStartBlock() <em>Start Block</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartBlock()
	 * @generated
	 * @ordered
	 */
	protected static final int START_BLOCK_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getStartBlock() <em>Start Block</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStartBlock()
	 * @generated
	 * @ordered
	 */
	protected int startBlock = START_BLOCK_EDEFAULT;

	/**
	 * The default value of the '{@link #getStatus() <em>Status</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStatus()
	 * @generated
	 * @ordered
	 */
	protected static final AppointmentStatus STATUS_EDEFAULT = AppointmentStatus.ACTIVE_LITERAL;

	/**
	 * The cached value of the '{@link #getStatus() <em>Status</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getStatus()
	 * @generated
	 * @ordered
	 */
	protected AppointmentStatus status = STATUS_EDEFAULT;

	/**
	 * The cached value of the '{@link #getHasClients() <em>Has Clients</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHasClients()
	 * @generated
	 * @ordered
	 */
	protected EList hasClients;

	/**
	 * The cached value of the '{@link #getServices() <em>Services</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServices()
	 * @generated
	 * @ordered
	 */
	protected EList services;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AppointmentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return ClinicPackage.Literals.APPOINTMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDate(Date newDate) {
		Date oldDate = date;
		date = newDate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.APPOINTMENT__DATE, oldDate, date));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getStartBlock() {
		return startBlock;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStartBlock(int newStartBlock) {
		int oldStartBlock = startBlock;
		startBlock = newStartBlock;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.APPOINTMENT__START_BLOCK, oldStartBlock, startBlock));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AppointmentStatus getStatus() {
		return status;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setStatus(AppointmentStatus newStatus) {
		AppointmentStatus oldStatus = status;
		status = newStatus == null ? STATUS_EDEFAULT : newStatus;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.APPOINTMENT__STATUS, oldStatus, status));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getHasClients() {
		if (hasClients == null) {
			hasClients = new EObjectContainmentEList(Client.class, this, ClinicPackage.APPOINTMENT__HAS_CLIENTS);
		}
		return hasClients;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getServices() {
		if (services == null) {
			services = new EObjectContainmentEList(Service.class, this, ClinicPackage.APPOINTMENT__SERVICES);
		}
		return services;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getCost() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean cancel() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getTimeLength() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ClinicPackage.APPOINTMENT__HAS_CLIENTS:
				return ((InternalEList)getHasClients()).basicRemove(otherEnd, msgs);
			case ClinicPackage.APPOINTMENT__SERVICES:
				return ((InternalEList)getServices()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ClinicPackage.APPOINTMENT__DATE:
				return getDate();
			case ClinicPackage.APPOINTMENT__START_BLOCK:
				return new Integer(getStartBlock());
			case ClinicPackage.APPOINTMENT__STATUS:
				return getStatus();
			case ClinicPackage.APPOINTMENT__HAS_CLIENTS:
				return getHasClients();
			case ClinicPackage.APPOINTMENT__SERVICES:
				return getServices();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ClinicPackage.APPOINTMENT__DATE:
				setDate((Date)newValue);
				return;
			case ClinicPackage.APPOINTMENT__START_BLOCK:
				setStartBlock(((Integer)newValue).intValue());
				return;
			case ClinicPackage.APPOINTMENT__STATUS:
				setStatus((AppointmentStatus)newValue);
				return;
			case ClinicPackage.APPOINTMENT__HAS_CLIENTS:
				getHasClients().clear();
				getHasClients().addAll((Collection)newValue);
				return;
			case ClinicPackage.APPOINTMENT__SERVICES:
				getServices().clear();
				getServices().addAll((Collection)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case ClinicPackage.APPOINTMENT__DATE:
				setDate(DATE_EDEFAULT);
				return;
			case ClinicPackage.APPOINTMENT__START_BLOCK:
				setStartBlock(START_BLOCK_EDEFAULT);
				return;
			case ClinicPackage.APPOINTMENT__STATUS:
				setStatus(STATUS_EDEFAULT);
				return;
			case ClinicPackage.APPOINTMENT__HAS_CLIENTS:
				getHasClients().clear();
				return;
			case ClinicPackage.APPOINTMENT__SERVICES:
				getServices().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ClinicPackage.APPOINTMENT__DATE:
				return DATE_EDEFAULT == null ? date != null : !DATE_EDEFAULT.equals(date);
			case ClinicPackage.APPOINTMENT__START_BLOCK:
				return startBlock != START_BLOCK_EDEFAULT;
			case ClinicPackage.APPOINTMENT__STATUS:
				return status != STATUS_EDEFAULT;
			case ClinicPackage.APPOINTMENT__HAS_CLIENTS:
				return hasClients != null && !hasClients.isEmpty();
			case ClinicPackage.APPOINTMENT__SERVICES:
				return services != null && !services.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (date: ");
		result.append(date);
		result.append(", startBlock: ");
		result.append(startBlock);
		result.append(", status: ");
		result.append(status);
		result.append(')');
		return result.toString();
	}

} //AppointmentImpl
